using System;
using System.Collections.Generic;
using System.Text;

namespace Zsa.Reflection.Discovery
{
    /// <summary>
    /// Discovery attribute that encapsulates a single type.
    /// </summary>
    public class DiscoveryTypeAttribute : DiscoveryAttribute
    {
        #region Fields
        /// <summary>
        /// The type name
        /// </summary>
        private string _TypeName;
        #endregion Fields 

        #region Constructor
        /// <summary>
        /// Initializes a new instance of the <see cref="InstanceProviderAttribute"/> class.
        /// </summary>
        /// <param name="type">The type.</param>
        public DiscoveryTypeAttribute(Type type)
            : this ( type.FullName)
        {
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="DiscoveryTypeAttribute"/> class.
        /// </summary>
        /// <param name="typeName">Name of the type.</param>
        public DiscoveryTypeAttribute(string typeName)
        {
            _TypeName = typeName;
        }

        #endregion Constructor
        
        #region Properties
        /// <summary>
        /// Gets the name of the type.
        /// </summary>
        /// <value>The name of the type.</value>
        public string TypeName
        {
            get
            {
                return _TypeName;
            }
        }

        #endregion Properties

        #region Methods
        /// <summary>
        /// Creates the type.
        /// </summary>
        /// <returns></returns>
        public Type CreateType()
        {
            return Type.GetType(_TypeName);
        }
        #endregion Methods
    }
}
